MV_GIGE_SetIpConfig

MV_GIGE_SetIpConfig

Configure IP mode.

API Definition

int MV_GIGE_SetIpConfig(
  void            *handle,
  unsigned int    nType
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

nType

[IN] IP configuration mode, see the details below:

Macro Definition

Value

Description

MV_IP_CFG_STATIC

0x05000000

Static mode

MV_IP_CFG_DHCP

0x06000000

DHCP mode

MV_IP_CFG_LLA

0x04000000

LLA (Link-local address)

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

  • This API is valid only when the IP address is reachable, and after calling this API, the camera will reboot.

  • Send command to set the MVC IP configuration mode, such as DHCP, LLA, and so on. This API is only supported by GigEVision camera.

The following sample code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Set device IP address
    unsigned int nType = MV_IP_CFG_STATIC; //Static IP address mode
    nRet = MV_GIGE_SetIpConfig(m_handle, nType);
    if (MV_OK != nRet)
    {
        printf("error: SetIpConfig fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

MV_GIGE_SetIpConfig

Configure IP mode.

API Definition

int MV_GIGE_SetIpConfig(
  void            *handle,
  unsigned int    nType
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

nType

[IN] IP configuration mode, see the details below:

Macro Definition

Value

Description

MV_IP_CFG_STATIC

0x05000000

Static mode

MV_IP_CFG_DHCP

0x06000000

DHCP mode

MV_IP_CFG_LLA

0x04000000

LLA (Link-local address)

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

  • This API is valid only when the IP address is reachable, and after calling this API, the camera will reboot.

  • Send command to set the MVC IP configuration mode, such as DHCP, LLA, and so on. This API is only supported by GigEVision camera.

The following sample code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Set device IP address
    unsigned int nType = MV_IP_CFG_STATIC; //Static IP address mode
    nRet = MV_GIGE_SetIpConfig(m_handle, nType);
    if (MV_OK != nRet)
    {
        printf("error: SetIpConfig fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}